package com.window;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import com.database.DataBaseService;
import com.database.TableVo;

public class DefineTable extends AbstractTableModel {

//	Object[][] p = {
//			{false, "tsys_user", "用户表","",""},
//			{ true,"tsys_userlog", "用户日志" ,"",""}};
	static Object [][]  p =null;
	
	static{
		List<TableVo> ls = new DataBaseService().getAllTableNames();
		p =  new Object[ls.size()][4];
		int i = 0;
		for (TableVo tab : ls) {
			Object [] objsub = new Object[5];
			objsub[0] = false;
			objsub[1] = tab.getTableName();
			objsub[2] = tab.getTableComment();
			objsub[3] = tab.getTableName();
			objsub[4] = tab.getTableName();
			p[i++] = objsub;
		}
	}

	String[] n = {  "","表编码", "表名称","实体类名称","页面名称"};

	@Override
	public int getRowCount() {
		return p.length;
	}

	@Override
	public int getColumnCount() {
		return n.length;
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return p[rowIndex][columnIndex];
	}

	@Override
	public String getColumnName(int column) {
		return n[column];
	}

	@Override
	public Class<?> getColumnClass(int columnIndex) {
		return getValueAt(0, columnIndex).getClass();
	}

	@Override
	public boolean isCellEditable(int rowIndex, int columnIndex) {
		return true;
	}

	@Override
	public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
		p[rowIndex][columnIndex] = aValue;
		fireTableCellUpdated(rowIndex, columnIndex);
	}
}
